package com.eqdd.yiqidian.utils;

import android.content.Context;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.text.InputType;
import android.util.Log;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.eqdd.yiqidian.R;
import com.eqdd.yiqidian.base.BaseActivity;
import com.eqdd.yiqidian.base.Config;
import com.eqdd.yiqidian.bean.BaseBean;
import com.eqdd.yiqidian.bean.rebuild.FriendListResultBean;
import com.eqdd.yiqidian.http.HttpConfig;
import com.eqdd.yiqidian.http.HttpPresneter;
import com.eqdd.yiqidian.ui.yiqiyue.YueMenuListActivity;

import java.util.HashMap;

/**
 * Created by lv on 17-8-16.
 */

public class DialogUtil {
    public static AlertDialog tip(Context context, String msg, OnEnsureListenner onEnsureListenner) {

        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setMessage(msg);
        builder.setTitle("提示");
        builder.setPositiveButton("确认", (dialog, which) -> {
            dialog.dismiss();
            onEnsureListenner.ensure();

        });
        builder.setNegativeButton("取消", (DialogInterface dialog, int which) -> {
                    dialog.dismiss();
                }
        );
        return builder.create();
    }

    public static void edit(Context context, String title, String content, String hint, MaterialDialog.SingleButtonCallback singleButtonCallback) {
        new MaterialDialog.Builder(context)
                .title(title)
                .input(hint, content, false, (dialog, input) -> {
                    System.out.println(input);
                    System.out.println(dialog.getInputEditText().length());
                    if (dialog.getInputEditText().length() <= 0) {
                        dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
                    } else {
                        dialog.getActionButton(DialogAction.POSITIVE).setEnabled(true);
                    }
                })
                .onPositive(singleButtonCallback)
                .show();
    }

    public interface OnEnsureListenner {
        void ensure();
    }

}
